import React, { Component } from 'react';
import { StyleSheet, View, Dimensions, Text } from "react-native";

const ScreenWidth = Dimensions.get('window').width;
const scale = ScreenWidth / 375;

export class ParentBox extends Component {
	constructor(props) {
		super(props);
	}


	componentWillReceiveProps (props) {
		console.log('执行了', props)
	}

	shouldComponentUpdate (nextProps, nextState) {
		if (this.props.data !== nextProps.data) {
			return true;
		}
		return false;
	}


	render () {
		console.log('更新子组件', this.props)
		return (
			<View style={styles.boxs}>
				<Text style={{ color: this.props.color }}>我是子组件</Text>
			</View>
		)
	}
}

const styles = StyleSheet.create({
	boxs: {
		backgroundColor: '#fff',
		borderRadius: 6 * scale,
		paddingHorizontal: 15 * scale,
		paddingVertical: 10 * scale,
		marginBottom: 15 * scale
	}
})